{{- if $.Values.global.modulesImages.registry.dockercfg }}
---
apiVersion: v1
kind: Secret
metadata:
  name: deckhouse-registry
  namespace: d8-system
  annotations:
    helm.sh/resource-policy: keep
{{- /* Helm checks changes only in .dockerconfigjson field, so if other field changes, helm don't change secret. Checksum resolve this. */}}
    checksum: {{ printf $.Values.global.modulesImages.registry.dockercfg $.Values.global.modulesImages.registry.address $.Values.global.modulesImages.registry.path $.Values.global.modulesImages.registry.scheme $.Values.global.modulesImages.registry.CA | sha256sum }}
  {{- include "helm_lib_module_labels" (list . (dict "app" "registry" "name" "deckhouse-registry")) | nindent 2 }}
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: {{ $.Values.global.modulesImages.registry.dockercfg }}
  address:           {{ $.Values.global.modulesImages.registry.address | b64enc }}
  {{- if $.Values.global.modulesImages.registry.path }}
  path:              {{ $.Values.global.modulesImages.registry.path | b64enc }}
  {{- end }}
  scheme:            {{ $.Values.global.modulesImages.registry.scheme | b64enc }}
  {{- if $.Values.global.modulesImages.registry.CA }}
  ca:                {{ $.Values.global.modulesImages.registry.CA | b64enc }}
  {{- end }}
---
apiVersion: v1
kind: Secret
metadata:
  name: deckhouse-registry
  namespace: kube-system
  annotations:
    helm.sh/resource-policy: keep
  {{- include "helm_lib_module_labels" (list .) | nindent 2 }}
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: {{ $.Values.global.modulesImages.registry.dockercfg }}
---
apiVersion: v1
kind: Secret
metadata:
  name: deckhouse-registry
  namespace: d8-monitoring
  annotations:
    helm.sh/resource-policy: keep
  {{- include "helm_lib_module_labels" (list .) | nindent 2 }}
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: {{ $.Values.global.modulesImages.registry.dockercfg }}
{{- end }}
